using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Drawing;

namespace GaDeTrung
{
    public class Egg
    {
        private PictureBox ptBox;
        private int speed = 6;
        public bool isEgg;
        private Random random = new Random();

        public int Top
        {
            set { this.ptBox.Top = value; }
            get { return this.ptBox.Top; }
        }

        public int Left
        {
            set { ptBox.Left = value; }
            get { return ptBox.Left; }
        }

        public int Speed
        {
            set { speed = value; }
            get { return speed; }
        }

        public Egg()
        {
            ptBox = new PictureBox();
            ptBox.Size = new Size(45, 48);
            ptBox.SizeMode = PictureBoxSizeMode.StretchImage;
            int r = random.Next(0, 3);
            if (r == 1)
            {
                ptBox.Image = Properties.Resources.shit;
                isEgg = false;
            }
            else
            {
                ptBox.Image = Properties.Resources.egg;
                isEgg = true;
            }
            ptBox.BackColor = Color.Transparent;
            // speed = 15;
        }

        public void AddToParent(Form form)
        {
            form.Controls.Add(ptBox);
        }
		
		public void Draw()
		{
			ptBox.Update();
		}

        public void UpdatePositionEgg()
        {
            this.Top += speed;
            // if (this.Top > 520)
            // {
                // RemoveFromParent();
            // }
        }

        //private bool CheckFloorCollision(int yFloor)
        //{
        //    return (this.Bottom > yFloor);
        //}

        public void RemoveFromParent()
        {
            if (ptBox.Parent != null)
            {
                ptBox.Parent.Controls.Remove(ptBox);
            }
        }
    }
}
